home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 022 / lemacs / vt52.c < prev    next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  115 lines

  1. /*
  2.  * The routines in this file
  3.  * provide support for VT52 style terminals
  4.  * over a serial line. The serial I/O services are
  5.  * provided by routines in "termio.c". It compiles
  6.  * into nothing if not a VT52 style device. The
  7.  * bell on the VT52 is terrible, so the "beep"
  8.  * routine is conditionalized on defining BEL.
  9.  */
  10. #define    termdef    1            /* don't define "term" external */
  11.  
  12. #include        <stdio.h>
  13. #include        "estruct.h"
  14. #include    "edef.h"
  15.  
  16. #if     VT52
  17.  
  18. #define NROW    24                      /* Screen size.                 */
  19. #define NCOL    80                      /* Edit if you want to.         */
  20. #define    MARGIN    8            /* size of minimim margin and    */
  21. #define    SCRSIZ    64            /* scroll size for extended lines */
  22. #define BIAS    0x20                    /* Origin 0 coordinate bias.    */
  23. #define ESC     0x1B                    /* ESC character.               */
  24. #define BEL     0x07                    /* ascii bell character         */
  25.  
  26. extern  int     ttopen();               /* Forward references.          */
  27. extern  int     ttgetc();
  28. extern  int     ttputc();
  29. extern  int     ttflush();
  30. extern  int     ttclose();
  31. extern  int     vt52move();
  32. extern  int     vt52eeol();
  33. extern  int     vt52eeop();
  34. extern  int     vt52beep();
  35. extern  int     vt52open();
  36. extern    int    vt52rev();
  37.  
  38. /*
  39.  * Dispatch table. All the
  40.  * hard fields just point into the
  41.  * terminal I/O code.
  42.  */
  43. TERM    term    = {
  44.         NROW-1,
  45.         NCOL,
  46.     MARGIN,
  47.     SCRSIZ,
  48.         &vt52open,
  49.         &ttclose,
  50.         &ttgetc,
  51.         &ttputc,
  52.         &ttflush,
  53.         &vt52move,
  54.         &vt52eeol,
  55.         &vt52eeop,
  56.         &vt52beep,
  57.         &vt52rev
  58. };
  59.  
  60. vt52move(row, col)
  61. {
  62.         ttputc(ESC);
  63.         ttputc('Y');
  64.         ttputc(row+BIAS);
  65.         ttputc(col+BIAS);
  66. }
  67.  
  68. vt52eeol()
  69. {
  70.         ttputc(ESC);
  71.         ttputc('K');
  72. }
  73.  
  74. vt52eeop()
  75. {
  76.         ttputc(ESC);
  77.         ttputc('J');
  78. }
  79.  
  80. vt52rev(status)    /* set the reverse video state */
  81.  
  82. int status;    /* TRUE = reverse video, FALSE = normal video */
  83.  
  84. {
  85.     /* can't do this here, so we won't */
  86. }
  87.  
  88. vt52beep()
  89. {
  90. #ifdef  BEL
  91.         ttputc(BEL);
  92.         ttflush();
  93. #endif
  94. }
  95.  
  96. #endif
  97.  
  98. vt52open()
  99. {
  100. #if     V7
  101.         register char *cp;
  102.         char *getenv();
  103.  
  104.         if ((cp = getenv("TERM")) == NULL) {
  105.                 puts("Shell variable TERM not defined!");
  106.                 exit(1);
  107.         }
  108.         if (strcmp(cp, "vt52") != 0 && strcmp(cp, "z19") != 0) {
  109.                 puts("Terminal type not 'vt52'or 'z19' !");
  110.                 exit(1);
  111.         }
  112. #endif
  113.         ttopen();
  114. }
  115.